home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / YICN23.ZIP / UNITS / SCRIPT.CPP < prev    next >
C/C++ Source or Header  |  1992-11-12  |  1KB  |  41 lines

  1. #include "script.h"
  2. // script.cpp is the file used to form actor scripts.
  3. // following are the defined commands.
  4.  
  5. scriptNode::scriptNode(byte icommand, int ix, int iy, int isquareX, int isquareY)
  6. {
  7.   command = icommand;
  8.   mapX = ix;
  9.   mapY = iy;
  10.   squareX = isquareX;
  11.   squareY = isquareY;
  12. }
  13. void script::advanceLine()
  14. {
  15.   if (thisLine != NULL)
  16.     thisLine = thisLine->nextLine;
  17. }
  18.  
  19. void script::addLine(byte command, int mapX, int mapY, int squareX, int squareY)
  20. {
  21.   if (firstLine == NULL)
  22.     firstLine = thisLine = lastLine = new scriptNode(command, mapX, mapY, squareX, squareY);
  23.   else
  24.     {
  25.     lastLine->nextLine = new scriptNode(command, mapX, mapY, squareX, squareY);
  26.     lastLine = lastLine->nextLine;
  27.     }
  28.   lastLine->nextLine = NULL;
  29. }
  30.  
  31. void script::addCommand(scriptNode::scriptCommand command, int mapX, int mapY, int squareX, int squareY)
  32. {
  33.   switch(command)
  34.   {
  35.     case scriptNode::doNothing   :
  36.     case scriptNode::turn        :
  37.     case scriptNode::fineMoveRel :  addLine(command, mapX, mapY, squareX, squareY); break;
  38.     case scriptNode::fineSlide   :  for (int counter = 0; counter < mapX; ++counter)
  39.                       addLine(scriptNode::fineMoveRel, 0,0, squareX/mapX, squareY/mapX); break;
  40.   }
  41. }